package com.redis.controller;

import com.redis.config.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisController {

    @Autowired
    private RedisUtil redisUtil;

    @GetMapping("/getValue/{key}")
    public Object getValue(@PathVariable("key") String key) {
        return redisUtil.getCacheObject(key);
    }

    @GetMapping("/setValue/{key}/{value}")
    public void setValue(@PathVariable("key") String key, @PathVariable("value") String value) {
        redisUtil.setCacheObject(key, value);
    }
}
